AdvancedTable - Row selection bug fix
#3373
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
π Summary
Fixed a race condition in
HdsAdvancedTablewhere re-rendering the table via updating the@modelargumentcaused the internal state of selectable rows to be incorrectly wiped out.π οΈ Detailed description
The Problem
When the table
@modelupdates, it inserts the new DOM elements before destroying the old ones. This creates a momentary overlap wherethis._selectableRowscontains two entries for the same row (the stale instance and the fresh instance) sharing the sameselectionKey.Previously, the
willDestroyRowCheckboxmethod used.filter()to remove the row being destroyed. Because the old and new rows shared the sameselectionKeyduring this overlap window, the filter logic aggressively removed both entries. This left the internal tracking array empty.The Solution
Replaced the
.filter()logic with a more targeted.findIndex()and.splice()approach.Find: We locate the first index matching the selectionKey (which corresponds to the old row).
Splice: We remove exactly one item at that index.
The Results
This change ensures that during the lifecycle overlap, we only remove the stale DOM reference while keeping the newly inserted row intact. The cleanup now correctly leaves one valid entry remaining, preserving the integrity of the selection state.
π External links
Jira ticket: HDS-5636
π Component checklist
π¬ Please consider using conventional comments when reviewing this PR.
π PCI review checklist
Examples of changes to controls include access controls, encryption, logging, etc.
Examples include changes to operating systems, ports, protocols, services, cryptography-related components, PII processing code, etc.